<template>
  <div class="livelihood-list-content">
    <Navbar title="民生事件" :fooBack="true" @back="goback"/>
    <div class="content">
      <p class="title">{{questionText}}</p>

      <QuestionItem :list="questionList"></QuestionItem>

    </div>
  </div>
</template>

<script lang="ts" setup>
import { computed, ref, reactive, toRefs, watch, onActivated, getCurrentInstance } from 'vue'
import Navbar from '@/components/Navbar/index.vue'
import { useRouter, useRoute } from 'vue-router'
import EventServe from '@/api/event'
import Cookies from 'js-cookie'
import { useEventStore } from '@/store'
import { storeToRefs } from 'pinia'
import QuestionItem from "./components/QuestionItem.vue"

defineOptions({
  name: 'LivelihoodList'
})

const eventStore = useEventStore()
const { time } = storeToRefs(eventStore)
// const time = import.meta.env.VITE_APP_MINSHENG_TIME

const route = useRoute()
const router = useRouter()

const questionText = ref("")
// 获取重点诉求
const questionList = ref([])
const getAppealData = () => {
  EventServe.getKeyPersonInfoByConcatWords({time: time.value, str: route.query.str}).then(res=>{
    questionList.value = res.data
  })
}
// 重点人员详情
const getPeopleData = () => {
  EventServe.getKeyPersonInfoByPhone({time: time.value, lxfs: route.query.lxfs}).then(res=>{
    questionList.value = res.data
  })
}

if(route.query.type == "重点诉求"){
  questionText.value = route.query.str
  getAppealData()
}else{
  questionText.value = route.query.ldr
  getPeopleData()
}

const goback = () => {
  Cookies.set('event_tab', route.query.type == "重点诉求"? '0' : '1')
  router.back()
}

</script>

<script lang="ts">

</script>

<style lang="less" scoped>
.livelihood-list-content{
  .content{
    padding: 16px 12px 100px;
    overflow: auto;
    height: 100vh;
    overflow-y: scroll;
    box-sizing: border-box;
  }
  .title{
    color: #000000;
    font-weight: bold;
    font-size: 18px;
    padding-bottom: 12px;
    line-height: 22px;
  }
}
</style>
